'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /*
      Add altering commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.createTable('users', { id: Sequelize.INTEGER });
    */
    const { INTEGER, DATE, STRING, NOW } = Sequelize;
    await queryInterface.createTable('l_user', {
      user_id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      name: {
        type: STRING,
        defaultValue: '',
      },
      username: {
        type: STRING,
        defaultValue: '',
        allowNull: false,
      },
      password: {
        type: STRING,
        defaultValue: '',
        allowNull: false,
      },
      avatar: {
        type: STRING,
        defaultValue: '',
      },
      status: {
        type: INTEGER,
        defaultValue: 1,
      },
      telephone: STRING,
      last_login_ip: STRING,
      last_login_at: STRING,
      role_id: {
        type: STRING,
        defaultValue: '',
      },
      created_at: {
        type: DATE,
        defaultValue: NOW,
      },
    });
  },

  down: async (queryInterface, Sequelize) => {
    /*
      Add reverting commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.dropTable('users');
    */
    await queryInterface.dropTable('user');
  },
};
